import hRequest from "@service/index";
import type { Tlogin } from "@/models/login";
import { Trestem } from "@/models/restem";
import { Tuser } from "@/models/user";
import { Tsourcefile } from "@/models/sourcefile";

export async function userlogin(data) {
    const res = await hRequest.get<Tlogin>({ url: "/user/login", params: data });
    return res;
}

export async function userregister(data) {
    const res = await hRequest.post<Tlogin>({ url: "/user/register", data: data }, "application/json");
    return res;
}

export async function usercode(params) {
    const res = await hRequest.get<Tlogin>({ url: "/user/getCode", params: params });
    return res;
}

export async function userupdata(data) {
    const res = await hRequest.put<Tlogin>({ url: "/user/update", data: data }, "application/json");
    return res;
}

export async function useruppw(data) {
    const res = await hRequest.put<Tlogin>({ url: "/user/update_pwd", data: data });
    return res;
}

export async function userlogout() {
    const res = await hRequest.get<Tlogin>({ url: "/user/logout" });
    return res;
}

export async function userpw(params) {
    const res = await hRequest.get<Tlogin>({ url: "/user/forgot", params: params });
    return res;
}

export async function get_user(params) {
    const res = await hRequest.get<Trestem & { data: Tuser }>({ url: "/user/get_user", params });
    return res;
}

export async function user_Verifica(data) {
    const res = await hRequest.post<Trestem & { data: Tsourcefile }>({ url: "/user/teacherCheck", data });
    return res;
}

export async function user_check(params) {
    const res = await hRequest.get<Trestem & { data: boolean }>({ url: "/code/check", params });
    return res;
}

export async function unlock_post(data) {
    const res = await hRequest.post<Trestem & { data: any }>({ url: "/code/unlock", data });
    return res;
}

export async function user_getCheckStatus(){
    const res = await hRequest.get<Trestem & { data:any }>({url:"/user/getCheckStatus"});
    return res;
}